package com.wcpdoc.survey.core.util;

public class Test {
	public static final String ISO_8859_1 = "ISO-8859-1";
	public static final String UTF_8 = "UTF-8";
	public static final String GBK = "GBK";
	public static final String GB2312 = "GB2312";

	public static void main(String[] args) {
		String str = new String("中国");
		System.out.println(changeCharset(changeCharset(str, UTF_8, ISO_8859_1), ISO_8859_1, ISO_8859_1));
		System.out.println(changeCharset(changeCharset(str, UTF_8, ISO_8859_1), ISO_8859_1, GBK));
		System.out.println(changeCharset(changeCharset(str, UTF_8, ISO_8859_1), ISO_8859_1, GB2312));
	}

	public static String changeCharset(String str, String oldCharset, String newCharset) {
		try {
			return new String(str.getBytes(oldCharset), newCharset);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
